from tortoise import fields, models
from tortoise.contrib.pydantic import pydantic_model_creator


class Product(models.Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=255)
    description = fields.TextField(null=True)
    image_path = fields.CharField(max_length=255)
    deleted = fields.BooleanField(default=False)  # 新增 deleted 字段

    class Meta:
        table = "products"


Product_Pydantic = pydantic_model_creator(Product, name="Product")
ProductIn_Pydantic = pydantic_model_creator(Product, name="ProductIn", exclude_readonly=True)


class Banner(models.Model):
    id = fields.IntField(pk=True)
    image_path = fields.CharField(max_length=255)
    text = fields.CharField(max_length=255, null=True)
    deleted = fields.BooleanField(default=False)  # 新增 deleted 字段

    class Meta:
        table = "banners"


Banner_Pydantic = pydantic_model_creator(Banner, name="Banner")
BannerIn_Pydantic = pydantic_model_creator(Banner, name="BannerIn", exclude_readonly=True)
